// 登录时密码错误的对话框

// 关闭VSCode非必要警告
// ignore_for_file: camel_case_types, sized_box_for_whitespace, must_be_immutable, non_constant_identifier_names

import 'package:flutter/material.dart';
import 'package:project_award_statistics/pages/desktop_adwaita/change_passwd_page/change_passwd_page.dart';
import 'package:project_award_statistics/utils/my_yaru_buttons/my_yaru_button_error_info.dart';
import 'package:yaru/yaru.dart';

class DialogLoginErr_WrongPasswd_Desktop extends StatelessWidget {
  String stu_name;     // 获取从登录页面传入的学生试图登录的姓名信息
  DialogLoginErr_WrongPasswd_Desktop({
    super.key,
    required this.stu_name,
  });

  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      backgroundColor: Theme.of(context).colorScheme.surface,
      // 设置登录错误标题,并关闭边距设置
      titlePadding: EdgeInsets.all(0),
      title: YaruDialogTitleBar(
        title: Text(
          "登录错误",
          style: TextStyle(
            fontSize: 18,
            fontWeight: FontWeight.bold,
          ),
        ),
        isClosable: false,  // 设置只允许按按钮关闭
      ),
      content: Container(
        height: 150,
        width: 460,
        child: Column(   // 设置列式布局容器
          children: [
            SizedBox(height: 20,),
            Text(
              "您输入的用户名或密码有误,请重新检查您的输入!",
              style: TextStyle(
                fontSize: 19,
              ),
            ),
            SizedBox(height: 50,),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                SizedBox(
                  height: 45,
                  width: 180,
                  child: MyYaruButton_ErrorInfo(
                    text: "哎呀,我忘记密码了", 
                    onPressed:() {
                      // 先关闭当前页面(对话框)
                      Navigator.of(context).pop();
                      // 再跳转修改密码界面
                      Navigator.push( 
                        context,
                        MaterialPageRoute(
                          builder: (context)=>ChangePasswdPage_Desktop(stu_name:stu_name,),    // 给密码错误页面传入学生试图填写的姓名信息,方便在密码更改页面时自动填充学生姓名               
                        )
                      );                      
                    },
                  ),
                ),
                const SizedBox(width: 2,),
                SizedBox(
                  height: 45,
                  width: 180,
                  child: MyYaruButton_ErrorInfo(
                    text: "好的,我马上去检查", 
                    onPressed: ()=>Navigator.of(context).pop(),
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
